from ultralytics import YOLO

if __name__ == '__main__':
    # 直接使用预训练模型创建模型.
    # model = YOLO('yolov8n.pt')
    # model.train(**{'cfg':'ultralytics/cfg/exp1.yaml', 'data':'dataset/data.yaml'})

    # pest24
    # model = YOLO('rice_pest24/yolov8s-cbg.yaml')
    # model.load('yolov8s.pt')
    # model.train(**{'cfg': 'rice_pest24/cfg.yaml', 'data': 'rice_pest24/ricepest-data.yaml'})

    # 使用yaml配置文件来创建模型,并导入预训练权重.
    # model = YOLO('ricepest_16/yolov8n.yaml')
    # model.load('yolov8n.pt')
    # model.train(**{'cfg': 'ricepest_16/cfg.yaml', 'data': 'ricepest_16/ricepest-data.yaml'})

    # 水稻虫情测报灯
    # model = YOLO('ricedata_cqcb/yolov8s-cbg.yaml')
    model = YOLO('ricedata_cqcb/yolov8m-cbg.yaml')
    model.load('yolov8m.pt')
    model.train(**{'cfg': 'ricedata_cqcb/cfg.yaml', 'data': 'ricedata_cqcb/ricepest-data.yaml'})



    # 模型验证
    # model = YOLO('runs/detect/train11/weights/best.pt')
    # model.val(**{'cfg':'ultralytics/cfg/PCB.yaml', 'data':'datasets/VOCPCB.yaml'})

    # 模型推理
    # model = YOLO('runs/detect/yolov8n_exp/best.pt')
    # model.predict(source='dataset/images/test', **{'save':True})

    # 模型导出
    # model = YOLO("Weight/yolov8n.pt")  # load an official model
    # model.export(format="onnx")
